<!-- 当前签约比例 -->
<template>
	<view class="container">
		<view class="indexBox">
			<text class="title">当前优惠力度（给消费者）</text>
			<view class="input">
				<input type="number" v-model="ratio" maxlength="2"/>
				<view>%</view>
			</view>
			<view class="desc">企业自营优惠比例不低于{{company_sign_ratio}}%，社区直营优惠比例不低于{{community_ratio_limit}}%</view>
		</view>
		<view class="loginBtn" @tap="submit">提交修改</view>
	</view>
</template>

<script>
	import {
		systemConfig
	} from '@/api/public.js'
	import { ratioModify } from '@/api/merchant.js'
	export default{
		components:{},
		data(){
			return {
				ratio: null,//比例
				company_sign_ratio: "",
				community_ratio_limit: ""
			}
		},
		created() {
			/**
			 * 获取签约比例说明
			 */
			systemConfig({
				filed: 'company_sign_ratio'
			}).then(res => {
				this.company_sign_ratio = res.msg;
			})
			systemConfig({
				filed: 'community_ratio_limit'
			}).then(res => {
				this.community_ratio_limit = res.msg;
			})
		},
		onLoad(option) {
			if(option.ratio == "undefined"){
				this.ratio = ""
			}else{
				this.ratio = Number(option.ratio);

			}
		},
		methods:{
			submit(){
				ratioModify({
					commission_ratio: Number(this.ratio)
				}).then(res => {
					if(res.status == 200){
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 1000
						})
					}
					setTimeout(function(){
						uni.navigateBack({})
					},1000)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		font-size: 28rpx;
		margin: 60rpx auto;
		width: 80%;
		.indexBox{
			.title{
				font-size:28rpx;
				font-weight:400;
				color:rgba(51,51,51,1);
			}
			.input{
				margin-top: 24rpx;
				border-bottom: 1px solid #EEEEEE;
				font-size:28rpx;
				font-family:Source Han Sans CN;
				font-weight:bold;
				color: #333333;
				display: flex;
				align-items: center;
				input{
					display: inline-block;
					width: 50rpx;
					height: 30rpx;
				}
			}
			.desc{
				font-size:20rpx;
				font-weight:400;
				color:rgba(212,212,212,1);
				margin-top: 10rpx;
			}
		}
		.loginBtn {
			position: fixed;
			bottom: 60rpx;
			left: 75rpx;
			width: 600rpx;
			height: 80rpx;
			border-radius: 40rpx;
			background: $theme-color;
			line-height: 80rpx;
			text-align: center;
			color: #ffffff;
			font-size: 32rpx;
		}
	}
</style>

